Title: SQL W3S (By-BKK) / 021 Wildcards
Tags: Obsidian_to_Anki

Q: What is the purpose of SQL wildcard characters?
A: To substitute one or more characters in a string

Q: Wildcard characters are used with which SQL operator?
A: LIKE operator

Q: What does the % wildcard represent in SQL?
A: Zero or more characters

Q: What does the _ wildcard represent in SQL?
A: A single character

Q: What does the [] wildcard represent in SQL?
A: Any single character within the brackets (not supported in PostgreSQL and MySQL)

Q: What does the ^ symbol represent when used inside [] in SQL?
A: Any character not in the brackets (not supported in PostgreSQL and MySQL)

Q: What does the - symbol represent inside [] in SQL?
A: Any single character within the specified range (not supported in PostgreSQL and MySQL)

Q: Which SQL wildcard is supported only in Oracle databases?
A: {} (Represents any escaped character)

Q: True/False: The % wildcard can match zero characters.
A: True

Q: True/False: The _ wildcard can match more than one character.
A: False

Q: What SQL statement returns all customers whose names start with 'a'?
A: SELECT * FROM Customers WHERE CustomerName LIKE 'a%';

Q: How would you match cities where the name ends with 'es'?
A: Use LIKE '%es'

Q: How do you select customers whose city starts with any character followed by 'ondon'?
A: SELECT * FROM Customers WHERE City LIKE '_ondon';

Q: Which pattern matches all customer names starting with b, s, or p?
A: LIKE '[bsp]%'

Q: How do you select customers whose names start with any letter from 'a' to 'f'?
A: LIKE '[a-f]%'

Q: How do you combine '%' and '_' wildcards in a LIKE pattern?
A: You can use both, e.g. LIKE 'a__%'

Q: How do you select customers with 'r' in the second position of their name?
A: LIKE '_r%'

Q: What result do you get if you use LIKE without wildcards?
A: An exact match

Q: Which database supports wildcards like *, ?, !, # in addition to SQL standard ones?
A: Microsoft Access

Q: How do you use the Microsoft Access wildcard * in a pattern?
A: Represents zero or more characters, e.g., bl* finds black, blue

Q: How would you use ? wildcard in Microsoft Access?
A: Represents a single character, e.g., h?t finds hot, hat, hit

Q: Give an example of [] wildcard for letter selection in Microsoft Access.
A: h[oa]t finds hot and hat, not hit

Q: Give an example of the ! wildcard for exclusion in Microsoft Access.
A: h[!oa]t finds hit but not hot and hat

Q: How is the # wildcard used in Microsoft Access?
A: Represents any single numeric character, e.g., 2#5 finds 205, 215, etc.

Q: Which operator uses SQL wildcards for pattern matching?
A: LIKE operator is used for pattern matching in SQL

Q: Which SQL LIKE pattern matches names starting with b, s, or p?
A: '[bsp]%' matches names starting with b, s, or p in SQL